﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMasterPage.Master" AutoEventWireup="true"
    CodeFile="ChiTietSanPham.aspx.cs" Inherits="Admin_ChiTietSanPham" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <h3>Chi tiết tài liệu</h3>
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="IDTaiLieu" DataSourceID="SqlDataSource1" OnItemUpdating="Updating" OnItemUpdated="Updated">
        <EditItemTemplate>
            <table class="table_ct_sp_edit">
                <tr>
                    <td class="trai ten">
                       Mã tài liệu:
                    </td>
                    <td class="ten">
                        <asp:TextBox ID="IDTaiLieuLabel1" runat="server" Text='<%# Eval("IDTaiLieu") %>' Enabled="false"/>
                    </td>
                </tr>
               
                <tr>
                    <td class="trai">
                        Tên tài liệu:
                    </td>
                    <td>
                        <asp:TextBox ID="TenTLTextBox" runat="server" Text='<%# Bind("TenTL") %>' />
                    </td>
                </tr>
                 <tr>
                    <td class="trai">
                        Thuộc loại:
                    </td>
                    <td>
                         <asp:DropDownList ID="ddlLoaiTLCha" runat="server" AppendDataBoundItems="true"
               DataSourceID="SqlDataSource2"
               DataTextField="TenLoaiTL"
               DataValueField="IDLoaiTL" selectedvalue='<%# Bind("IDLoaiTL") %>'
            >
            <asp:ListItem Value="0" Text="--Không có--"></asp:ListItem>
            </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Tác giả:
                    </td>
                    <td>
                        <asp:TextBox ID="TacGiaTextBox" runat="server" Text='<%# Bind("TacGia") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Mô tả:
                    </td>
                    <td>
                        <asp:TextBox ID="MoTaTextBox" TextMode="MultiLine" runat="server" Text='<%# Bind("MoTa") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Hình ảnh:
                    </td>
                    <td><asp:TextBox ID="TextBox1" Visible="false" runat="server" Text='<%# Bind("HinhAnh") %>' />
                        <asp:FileUpload ID="fuPicture" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Năm phát hành:
                    </td>
                    <td>
                        <asp:TextBox ID="NamPhatHanhTextBox" runat="server" Text='<%# Bind("NamPhatHanh") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Đơn giá:
                    </td>
                    <td>
                        <asp:TextBox ID="DonGiaTextBox" runat="server" Text='<%# Bind("DonGia") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Hiển thị tài liệu mới:
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlLoaiCopy" runat="server" selectedvalue='<%# Bind("TaiLieuMoi")%>'>
            <asp:ListItem Value="1" Text="Hiển thị"></asp:ListItem>
            <asp:ListItem Value="0" Text="Không hiển thị"></asp:ListItem>
            </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Thứ tự hiển thị:
                    </td>
                    <td>
                        <asp:TextBox ID="ThuTuHienThiTextBox" runat="server" Text='<%# Bind("ThuTuHienThi") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Trạng thái:
                    </td>
                    <td>
                         <asp:DropDownList ID="DropDownList1" runat="server" selectedvalue='<%# Bind("TrangThai")%>'>
            <asp:ListItem Value="1" Text="Còn hàng"></asp:ListItem>
            <asp:ListItem Value="0" Text="Hết hàng"></asp:ListItem>
            </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        License Key:
                    </td>
                    <td>
                        <asp:TextBox ID="LicenseTextBox" runat="server" Text='<%# Bind("License") %>' />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="bo_nut">
                        <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Cập nhật" CssClass="button"/>
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Bỏ qua" CssClass="button"/>
                    </td>
                </tr>
            </table>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <span>No data was returned.</span>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <span style="">IDLoaiTL:
                <asp:TextBox ID="IDLoaiTLTextBox" runat="server" Text='<%# Bind("IDLoaiTL") %>' />
                <br />
                TenTL:
                <asp:TextBox ID="TenTLTextBox" runat="server" Text='<%# Bind("TenTL") %>' />
                <br />
                TacGia:
                <asp:TextBox ID="TacGiaTextBox" runat="server" Text='<%# Bind("TacGia") %>' />
                <br />
                MoTa:
                <asp:TextBox ID="MoTaTextBox" runat="server" Text='<%# Bind("MoTa") %>' />
                <br />
                HinhAnh:
                <asp:TextBox ID="HinhAnhTextBox" runat="server" Text='<%# Bind("HinhAnh") %>' />
                <br />
                NamPhatHanh:
                <asp:TextBox ID="NamPhatHanhTextBox" runat="server" Text='<%# Bind("NamPhatHanh") %>' />
                <br />
                DonGia:
                <asp:TextBox ID="DonGiaTextBox" runat="server" Text='<%# Bind("DonGia") %>' />
                <br />
                TaiLieuMoi:
                <asp:TextBox ID="TaiLieuMoiTextBox" runat="server" Text='<%# Bind("TaiLieuMoi") %>' />
                <br />
                ThuTuHienThi:
                <asp:TextBox ID="ThuTuHienThiTextBox" runat="server" Text='<%# Bind("ThuTuHienThi") %>' />
                <br />
                TrangThai:
                <asp:TextBox ID="TrangThaiTextBox" runat="server" Text='<%# Bind("TrangThai") %>' />
                <br />
                License:
                <asp:TextBox ID="LicenseTextBox" runat="server" Text='<%# Bind("License") %>' />
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                <br />
                <br />
            </span>
        </InsertItemTemplate>
        <ItemTemplate>
            <table class="table_ct_sp">
                <tr>
                    <td class="trai ten">
                        Mã tài liệu:
                    </td>
                    <td class="ten">
                        <asp:Label ID="IDTaiLieuLabel" runat="server" Text='<%# Eval("IDTaiLieu") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Tên tài liệu:
                    </td>
                    <td>
                        <asp:Label ID="TenTLLabel" runat="server" Text='<%# Eval("TenTL") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Loại tài liệu:
                    </td>
                    <td>
                        <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("TenLoaiTLCha") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Tác giả:
                    </td>
                    <td>
                        <asp:Label ID="TacGiaLabel" runat="server" Text='<%# Eval("TacGia") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Mô tả:
                    </td>
                    <td style="padding-right: 70px">
                        <asp:Label ID="MoTaLabel" runat="server" Text='<%# Eval("MoTa") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Hình ảnh:
                    </td>
                    <td>
                        <img src="../Image/Sach/<%# Eval("HinhAnh") %>" width="100px" />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Năm phát hành:
                    </td>
                    <td>
                        <asp:Label ID="NamPhatHanhLabel" runat="server" Text='<%# Eval("NamPhatHanh") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Đơn giá:
                    </td>
                    <td>
                        <asp:Label ID="DonGiaLabel" runat="server" Text='<%# Eval("DonGia") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Tài liệu mới:
                    </td>
                    <td>
                        <asp:Label ID="TaiLieuMoiLabel" runat="server" Text='<%# Eval("TaiLieuMoi") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Thứ tự hiển thị:
                    </td>
                    <td>
                        <asp:Label ID="ThuTuHienThiLabel" runat="server" Text='<%# Eval("ThuTuHienThi") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        Trạng thái:
                    </td>
                    <td>
                        <asp:Label ID="TrangThaiLabel" runat="server" Text='<%# Eval("TrangThai") %>' />
                    </td>
                </tr>
                <tr>
                    <td class="trai">
                        License Key:
                    </td>
                    <td>
                        <asp:Label ID="LicenseLabel" runat="server" Text='<%# Eval("License") %>' />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="td_chitiet_sp" align="center">
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Chỉnh sửa" CssClass="button" />
                        <asp:Button ID="LinkButton1" runat="server" CssClass="button" PostBackUrl="~/Admin/QuanLySanPham.aspx"
                            Text="Quay về danh sách"></asp:Button>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
        <LayoutTemplate>
            <div id="itemPlaceholderContainer" runat="server" style="">
                <span runat="server" id="itemPlaceholder" />
            </div>
            <div style="">
            </div>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <span style="">IDTaiLieu:
                <asp:Label ID="IDTaiLieuLabel" runat="server" Text='<%# Eval("IDTaiLieu") %>' />
                <br />
                IDLoaiTL:
                <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
                <br />
                TenTL:
                <asp:Label ID="TenTLLabel" runat="server" Text='<%# Eval("TenTL") %>' />
                <br />
                TacGia:
                <asp:Label ID="TacGiaLabel" runat="server" Text='<%# Eval("TacGia") %>' />
                <br />
                MoTa:
                <asp:Label ID="MoTaLabel" runat="server" Text='<%# Eval("MoTa") %>' />
                <br />
                HinhAnh:
                <asp:Label ID="HinhAnhLabel" runat="server" Text='<%# Eval("HinhAnh") %>' />
                <br />
                NamPhatHanh:
                <asp:Label ID="NamPhatHanhLabel" runat="server" Text='<%# Eval("NamPhatHanh") %>' />
                <br />
                DonGia:
                <asp:Label ID="DonGiaLabel" runat="server" Text='<%# Eval("DonGia") %>' />
                <br />
                TaiLieuMoi:
                <asp:Label ID="TaiLieuMoiLabel" runat="server" Text='<%# Eval("TaiLieuMoi") %>' />
                <br />
                ThuTuHienThi:
                <asp:Label ID="ThuTuHienThiLabel" runat="server" Text='<%# Eval("ThuTuHienThi") %>' />
                <br />
                TrangThai:
                <asp:Label ID="TrangThaiLabel" runat="server" Text='<%# Eval("TrangThai") %>' />
                <br />
                License:
                <asp:Label ID="LicenseLabel" runat="server" Text='<%# Eval("License") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                <br />
                <br />
            </span>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:ConnectionStringMembership %>" DeleteCommand="DELETE FROM [TaiLieu] WHERE [IDTaiLieu] = @original_IDTaiLieu AND (([IDLoaiTL] = @original_IDLoaiTL) OR ([IDLoaiTL] IS NULL AND @original_IDLoaiTL IS NULL)) AND (([TenTL] = @original_TenTL) OR ([TenTL] IS NULL AND @original_TenTL IS NULL)) AND (([TacGia] = @original_TacGia) OR ([TacGia] IS NULL AND @original_TacGia IS NULL)) AND (([MoTa] = @original_MoTa) OR ([MoTa] IS NULL AND @original_MoTa IS NULL)) AND (([HinhAnh] = @original_HinhAnh) OR ([HinhAnh] IS NULL AND @original_HinhAnh IS NULL)) AND (([NamPhatHanh] = @original_NamPhatHanh) OR ([NamPhatHanh] IS NULL AND @original_NamPhatHanh IS NULL)) AND (([DonGia] = @original_DonGia) OR ([DonGia] IS NULL AND @original_DonGia IS NULL)) AND (([TaiLieuMoi] = @original_TaiLieuMoi) OR ([TaiLieuMoi] IS NULL AND @original_TaiLieuMoi IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([TrangThai] = @original_TrangThai) OR ([TrangThai] IS NULL AND @original_TrangThai IS NULL)) AND (([License] = @original_License) OR ([License] IS NULL AND @original_License IS NULL))"
        InsertCommand="INSERT INTO [TaiLieu] ([IDLoaiTL], [TenTL], [TacGia], [MoTa], [HinhAnh], [NamPhatHanh], [DonGia], [TaiLieuMoi], [ThuTuHienThi], [TrangThai], [License]) VALUES (@IDLoaiTL, @TenTL, @TacGia, @MoTa, @HinhAnh, @NamPhatHanh, @DonGia, @TaiLieuMoi, @ThuTuHienThi, @TrangThai, @License)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT *,(SELECT b2.[TenLoaiTL] FROM [LoaiTaiLieu] b2 WHERE b2.[IDLoaiTL] = b1.[IDLoaiTL]) as TenLoaiTLCha FROM [TaiLieu] b1 "
        UpdateCommand="UPDATE [TaiLieu] SET [IDLoaiTL] = @IDLoaiTL, [TenTL] = @TenTL, [TacGia] = @TacGia, [MoTa] = @MoTa, [HinhAnh] = @HinhAnh, [NamPhatHanh] = @NamPhatHanh, [DonGia] = @DonGia, [TaiLieuMoi] = @TaiLieuMoi, [ThuTuHienThi] = @ThuTuHienThi, [TrangThai] = @TrangThai, [License] = @License WHERE [IDTaiLieu] = @original_IDTaiLieu AND (([IDLoaiTL] = @original_IDLoaiTL) OR ([IDLoaiTL] IS NULL AND @original_IDLoaiTL IS NULL)) AND (([TenTL] = @original_TenTL) OR ([TenTL] IS NULL AND @original_TenTL IS NULL)) AND (([TacGia] = @original_TacGia) OR ([TacGia] IS NULL AND @original_TacGia IS NULL)) AND (([MoTa] = @original_MoTa) OR ([MoTa] IS NULL AND @original_MoTa IS NULL)) AND (([HinhAnh] = @original_HinhAnh) OR ([HinhAnh] IS NULL AND @original_HinhAnh IS NULL)) AND (([NamPhatHanh] = @original_NamPhatHanh) OR ([NamPhatHanh] IS NULL AND @original_NamPhatHanh IS NULL)) AND (([DonGia] = @original_DonGia) OR ([DonGia] IS NULL AND @original_DonGia IS NULL)) AND (([TaiLieuMoi] = @original_TaiLieuMoi) OR ([TaiLieuMoi] IS NULL AND @original_TaiLieuMoi IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([TrangThai] = @original_TrangThai) OR ([TrangThai] IS NULL AND @original_TrangThai IS NULL)) AND (([License] = @original_License) OR ([License] IS NULL AND @original_License IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_IDTaiLieu" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenTL" Type="String" />
            <asp:Parameter Name="original_TacGia" Type="String" />
            <asp:Parameter Name="original_MoTa" Type="String" />
            <asp:Parameter Name="original_HinhAnh" Type="String" />
            <asp:Parameter DbType="Date" Name="original_NamPhatHanh" />
            <asp:Parameter Name="original_DonGia" Type="Decimal" />
            <asp:Parameter Name="original_TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_TrangThai" Type="Int32" />
            <asp:Parameter Name="original_License" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="TenTL" Type="String" />
            <asp:Parameter Name="TacGia" Type="String" />
            <asp:Parameter Name="MoTa" Type="String" />
            <asp:Parameter Name="HinhAnh" Type="String" />
            <asp:Parameter DbType="Date" Name="NamPhatHanh" />
            <asp:Parameter Name="DonGia" Type="Decimal" />
            <asp:Parameter Name="TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="TrangThai" Type="Int32" />
            <asp:Parameter Name="License" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="TenTL" Type="String" />
            <asp:Parameter Name="TacGia" Type="String" />
            <asp:Parameter Name="MoTa" Type="String" />
            <asp:Parameter Name="HinhAnh" Type="String" />
            <asp:Parameter DbType="Date" Name="NamPhatHanh" />
            <asp:Parameter Name="DonGia" Type="Decimal" />
            <asp:Parameter Name="TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="TrangThai" Type="Int32" />
            <asp:Parameter Name="License" Type="String" />
            <asp:Parameter Name="original_IDTaiLieu" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenTL" Type="String" />
            <asp:Parameter Name="original_TacGia" Type="String" />
            <asp:Parameter Name="original_MoTa" Type="String" />
            <asp:Parameter Name="original_HinhAnh" Type="String" />
            <asp:Parameter DbType="Date" Name="original_NamPhatHanh" />
            <asp:Parameter Name="original_DonGia" Type="Decimal" />
            <asp:Parameter Name="original_TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_TrangThai" Type="Int32" />
            <asp:Parameter Name="original_License" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
     <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionStringMembership %>" 
        SelectCommand="SELECT [IDLoaiTL],[TenLoaiTL] FROM [LoaiTaiLieu]"></asp:SqlDataSource>
</asp:Content>
